//
//  BaseTableViewController.swift
//  Weibo
//
//  Created by 刘蒙 on 16/1/11.
//  Copyright © 2016年 liumeng. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate{

    var visitorLoginView :VisitorLoginView?
    
    var userLongin = false
    //这个方法是苹果专门为手动代码的方式加载view而设计的,
    //如果使用了这个方法,就意味着,sb / xib 的使用将会失效
    override func loadView() {
        //进行判断
        if userLongin {
            //代表登陆成功了
            super.loadView()
        }else {
            //如果失败了
            visitorLoginView = VisitorLoginView()
            
            visitorLoginView?.visitorLoginViewDelegate = self

            //visitorLoginView?.backgroundColor = UIColor.redColor()
            view = visitorLoginView
//            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
//            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
            
        }
    }
    
    
    //实现协议方法

    
    func userWillRegister() {
        print(__FUNCTION__)
     
   
    }
    
    func userWillLogin() {
        print(__FUNCTION__)
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        

    }


  

}
